home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
cne
/
reslt2.exe
/
RESULTS.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1992-03-15
|
11KB
|
403 lines
PROGRAM CNEResults;
(* Show progress on Novell's CNE Assessment Test V2.1. *)
(***************************************************************************)
(* Input : CNE~RSP.DAT - Response file to the CNE assessment Test. *)
(* Output : RESULTS.RPT - An ASCII file which can be viewed or printed. *)
(***************************************************************************)
(********************************************************************************************)
(* INPUT RECORD LOOKS LIKE THIS (view used by RESULTS V1.00): *)
(* CNE Assessment Test 2.0 : *)
(* ┌───┬──────────┬───┬─────────┬─────┬───┬─────────┬───┬───────┬────────┬───────┬────────┐ *)
(* │0Ch│FIRST_NAME│20h│LAST_NAME│0007h│63h│TEST_NAME│63h│SEC_NUM│00h..00h│ANSWERS│20h..20h│ *)
(* └───┴──────────┴───┴─────────┴─────┴───┴─────────┴───┴───────┴────────┴───────┴────────┘ *)
(********************************************************************************************)
(***********************************************************************************************************************)
(* CNE Assessment Test 2.1 (view used by RESULTS V2.10) : *)
(* ┌───┬──────────┬───┬─────────┬────────────────┬───┬─────────┬───┬───────┬────────────────────────┬───────┬────────┐ *)
(* │0Ch│FIRST_NAME│20h│LAST_NAME│non-(upperalpha)│63h│TEST_NAME│63h│SEC_NUM│non-(upperalpha/numeric)│ANSWERS│20h..20h│ *)
(* └───┴──────────┴───┴─────────┴────────────────┴───┴─────────┴───┴───────┴────────────────────────┴───────┴────────┘ *)
(* ├> 2 bytes <┤ ├> 10 bytes <┤ *)
(***********************************************************************************************************************)
(**********************************************************************************)
(* VERSION HISTORY : *)
(**********************************************************************************)
(* V1.00 2/16/92 - Initial version. Displays name, test, section, test results *)
(* (whether correct answer or choice was incorrect, and score. *)
(* Author : Eric J.G. Bonnell 73500,3250. *)
(**********************************************************************************)
(* V2.10 3/4/92 - Fix for Assessment Test V2.1. Seems to be compatable with 2.0. *)
(* Contributor : Eric J.G. Bonnell 73500,3250. *)
(**********************************************************************************)
(* V2.11 3/15/92 - Gives "File Not Found" message when no CNE~RSP.DAT. *)
(* Will not bomb if no questions found. Instead, will report *)
(* 0 questions and block out percentage with '***' *)
(* (i.e. no division by zero).
(* Contributor : Eric J.G. Bonnell 73500,3250. *)
(**********************************************************************************)
(* !!!!! NEXT Version Changes Go Here !!!!!!!!! *)
(**********************************************************************************)
USES
Dos,
Crt;
(* Standard I/O *)
CONST
NUL : Char = #$00;
Preamble : Char = #$0C;
Space : Char = #$20;
ResponseHeader : Char = #$07;
Letter_c : Char = #$63;
NessessaryCredits
= 'Compiled Using Turbo Pascal V6.0 (c) 1983,90 Borland International, Inc.';
VAR
InFile : Text;
(* CNE~RSP.DAT *)
OutFile : Text;
(* RESULTS.RPT *)
PROCEDURE Salutations;
(* Write an opening message on the screen. *)
BEGIN
WriteLn(ParamStr(0),' - CNE Assessment Test V2.x Results.');
WriteLn(' V2.11 (c) 1992 Eric J.G. Bonnell 73500,3250.');
WriteLn
END (* Salutations *);
PROCEDURE Goodbyes;
(* Let user know it is done. *)
BEGIN
WriteLn('Finished. Results are recorded in RESULTS.RPT.');
WriteLn
END (* GoodByes *);
FUNCTION IsAlpha(C : Char) : Boolean;
(* True if C is alphabetic. *)
BEGIN
IsAlpha := C IN ['A'..'Z','a'..'z']
END (* IsAlpha *);
FUNCTION IsNumeric(C : Char) : Boolean;
(* True if C is a decimal digit. *)
BEGIN
IsNumeric:= C IN ['0'..'9']
END (* IsNumeric *);
FUNCTION IsPreamble(C : Char) : Boolean;
(* True if C is 0Ch. *)
BEGIN
IsPreamble:= C = Preamble
END (* IsPreamble *);
FUNCTION IsSpace(C : Char) : Boolean;
(* True if C is 20h. *)
BEGIN
IsSpace := C = Space
END (* IsSpace *);
FUNCTION IsNul(C : Char) : Boolean;
(* True if C is 00h. *)
BEGIN
IsNul := C = NUL
END (* IsNul *);
FUNCTION IsCntrl(C : Char) : Boolean;
(* True if C is not alphanumeric (not nessessarily a control character). *)
BEGIN
IsCntrl := NOT IsAlpha(C) AND NOT IsNumeric(C)
END (* IsCntrl *);
FUNCTION IsResponseHeader(C : Char) : Boolean;
(* True if C iss 07h. *)
BEGIN
IsResponseHeader := C = ResponseHeader
END (* IsResponseHeader *);
FUNCTION IsLetter_c(C : Char) : Boolean;
(* True if C is a lowercase letter 'c'. *)
BEGIN
IsLetter_c := C = Letter_c
END (* IsLetter_c *);
FUNCTION IsNonUpperAlpha(C : Char) : Boolean;
(* True if C is not capital letter. *)
BEGIN
IsNonUpperAlpha := NOT (C IN ['A'..'Z'])
END (* IsNonUpperAlpha *);
FUNCTION UpperCase(S : String) : String;
(* Convert S to all upper case characters. *)
VAR
I : 0..255;
BEGIN
I := Length(S);
WHILE I > 0 DO
BEGIN
S[I] := UpCase(S[I]);
Dec(I)
END;
UpperCase := S
END (* UpperCase *);
FUNCTION NoMore(VAR F : Text) : Boolean;
(* True if end-of-file found, otherwise found next record. *)
VAR
C : Char;
BEGIN
C := #$FF;
REPEAT
Read(F,C);
NoMore := EoF(F)
UNTIL IsPreamble(C) OR EoF(F)
END (* NoMore *);
PROCEDURE OpenFiles(VAR F,
O : Text);
VAR
S : SearchRec;
(* Open input and output files. *)
BEGIN
FindFirst('CNE~RSP.DAT',AnyFile,S);
IF DosError <> 0 THEN
BEGIN
WriteLn('CNE~RSP.DAT file not found!');
Halt(1)
END;
Assign(F,'CNE~RSP.DAT');
ReSet(F);
Assign(O,'RESULTS.RPT');
ReWrite(O)
END (* OpenFiles *);
PROCEDURE CloseFiles(VAR F,
O : Text);
(* Close input and output files. *)
BEGIN
Close(F);
Close(O)
END (* CloseFiles *);
FUNCTION FirstName(VAR F : Text) : String;
(* Retrieve FIRST_NAME from current record in file F. *)
VAR
S : String;
C : Char;
BEGIN
S := '';
C := #$00;
WHILE (NOT EoF(F)) AND (NOT IsSpace(C)) DO
BEGIN
Read(F,C);
S[0] := Chr(Ord(S[0]) + 1);
S[Ord(S[0])] := C
END;
FirstName := UpperCase(S)
END (* FirstName *);
FUNCTION LastName(VAR F : Text) : String;
(* Retrieve LAST_NAME from current record in file F. *)
VAR
S : String;
C : Char;
BEGIN
S := '';
C := #$FF;
Read(F,C);
WHILE (NOT EoF(F)) AND NOT IsNonUpperAlpha(C) DO
BEGIN
S[0] := Chr(Ord(S[0]) + 1);
S[Ord(S[0])] := C;
Read(F,C)
END;
LastName := UpperCase(S)
END (* LastName *);
FUNCTION TestName(VAR F : Text) : String;
(* Retrieve TEST_NAME from current record in file F. *)
VAR
S : String;
I : 0..3;
C : Char;
BEGIN
S := '';
C := #$00;
FOR I := 1 TO 3 DO
Read(F,C);
FOR I := 1 TO 3 DO
BEGIN
S[0] := Chr(Ord(S[0]) + 1);
S[Ord(S[0])] := C;
Read(F,C)
END;
TestName := UpperCase(S)
END (* TestName *);
FUNCTION SectionNumber(VAR F : Text) : Integer;
(* Retrieve SEC_NUM from current record in file F. *)
VAR
Code : Integer;
Value : Integer;
S : String;
C : Char;
BEGIN
S := '';
C := #$00;
WHILE (NOT Eof(F)) AND IsResponseHeader(C) DO
Read(F,C);
Read(F,C);
FOR Code := 1 TO 2 DO
BEGIN
S[0] := Chr(Ord(S[0]) + 1);
S[Ord(S[0])] := C;
Read(F,C)
END;
Val(S,Value,Code);
SectionNumber := Value
END (* SectionNumber *);
FUNCTION QuestionStatus(VAR F : Text;
VAR Q : Integer;
VAR I : Integer;
VAR N : Integer;
VAR C : Char) : String;
(* Determine the results of Question Q in current record in F.
tally I correct responces for N total questions, passing back
the next field C in record. *)
VAR
S : String;
T : String;
BEGIN
S := '';
Str(Q,S);
IF Length(S) < 2 THEN
S := ' ' + S;
T[0] := Chr(1);
T[1] := C;
T := UpperCase(T);
Inc(N);
IF IsNumeric(C) THEN
BEGIN
Inc(I);
QuestionStatus := 'Question ' + S + ' was answered correctly.'
END
ELSE
QuestionStatus := 'Question ' + S + ' was incorrectly answered! [' + T + ']';
Inc(Q);
Read(F,C)
END (* QuestionStatus *);
PROCEDURE ListEm(VAR F : Text;
VAR O : Text;
VAR I : Integer;
VAR N : Integer);
(* Step through all the responses until there are no more in F.
Write a status for the response in O and tally I correct responses
for N total questions. *)
VAR
C : Char;
Q : Integer;
Waste : 0..10;
BEGIN
Q := 1;
C := #$FF;
C := #$FF;
FOR Waste := 1 TO 10 DO
Read(F,C);
WHILE (NOT EoF(F)) AND (NOT IsSpace(C)) DO
WriteLn(O,QuestionStatus(F,Q,I,N,C))
END (* ListEm *);
PROCEDURE DoIt(VAR F,
O : Text);
(* List out the information in file F into ASCII text output file O. *)
VAR
Percentage : Real;
InvalPercent : String;
I : Integer;
N : Integer;
BEGIN
WriteLn(O,'────────────── CNE Assessment Test Results ───────────────');
WHILE NOT NoMore(F) DO
BEGIN
Percentage := 0.0;
I := 0;
N := 0;
WriteLn(O);
WriteLn(O,'TESTED : ',FirstName(F),' ',LastName(F),'.');
WriteLn(O);
WriteLn(O,'COURSE : ',TestName(F),' SECTION : ',SectionNumber(F));
WriteLn(O);
ListEm(F,O,I,N);
IF N = 0 THEN
InvalPercent := '***'
ELSE
Percentage := I / N * 100;
WriteLn(O);
WriteLn(O);
IF N = 0 THEN
WriteLn(O,'SCORE : ',I,' Correct out of ',N,' = ',InvalPercent,'%.')
ELSE
WriteLn(O,'SCORE : ',I,' Correct out of ',N,' = ',Percentage:5:2,'%.');
WriteLn(O);
WriteLn(O,'──────────────────────────────────────────────────────────')
END
END (* DoIt *);
BEGIN (* main *)
Salutations;
OpenFiles(InFile,OutFile);
DoIt(InFile,OutFile);
CloseFiles(InFile,OutFile);
Goodbyes
END.